<?php
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers');
?>
<div class="viewCategory">

	<!-- PAGE HEADING -->
	<?php if ($this->params->get('show_page_heading', 1)) : ?>
	<h1 class="pageHeading">
	<?php echo $this->escape($this->params->get('page_heading')); ?>
	</h1>
	<?php endif; ?>    
	
    <?php if ($this->params->get('show_description_image') || $this->params->get('show_description') || $this->params->get('show_cat_num_articles',1) ) : ?>
	<div class="catHeader">    
        <?php if ($this->params->get('show_description_image') && $this->category->getParams()->get('image')) : ?>
    	<div class="catImage"><img src="<?php echo $this->category->getParams()->get('image'); ?>" alt="<?php echo $this->escape($this->params->get('page_title')); ?>"/></div>
        <?php endif; ?>
                 
        <?php if ($this->params->get('show_description') && $this->category->description) : ?>
		<div class="catDesc"><?php echo JHtml::_('content.prepare', $this->category->description); ?></div>
		<?php endif; ?>	
        
	     <?php if ( $this->params->get('show_cat_num_articles',1)) : ?>
         <div class="catCounter"><?php echo JText::_('COM_CONTENT_NUM_ITEMS'); ?> <?php echo $this->category->numitems;?></div>  
         <?php endif;?>
         <div class="clr"></div>
    </div>  
    <?php endif;?>
    
    <?php if (!empty($this->children[$this->category->id])&& $this->maxLevel != 0) : ?>
    <div class="catSubList">
    	<?php echo $this->loadTemplate('subcat'); ?>
        <div class="clr"></div>
    </div>
    <?php endif;?>
    
    <?php $leadingcount=0 ; ?>
    <?php if (!empty($this->lead_items)) : ?>    
   		<div class="catLeadingList">
    	<?php foreach ($this->lead_items as $key=>&$item) : ?>
        	<div class="leadingItem<?php if($key+1==sizeof($this->lead_items)) echo ' last';?>">    	
        <?php
				$this->item = &$item;
				echo $this->loadTemplate('leading');
			?>
            </div>       
        <?php
			$leadingcount++;
		?>
        <?php endforeach; ?>
        <div class="clr"></div>
    </div>
    <?php endif;?>   
    
    <?php
	$introcount=(count($this->intro_items));
	$counter=0;
	?>
	<?php if (!empty($this->intro_items)) : ?>
		<div class="catIntroList">
	<?php foreach ($this->intro_items as $key => &$item) : ?>
	<?php
		$key= $key-$leadingcount;		
		 ?>
        <div class="introItem<?php if($key+1==sizeof($this->intro_items)) echo ' last';?>">                  	          	
		<?php
			$this->item = &$item;
			echo $this->loadTemplate('intro');
		?>
        </div>

	<?php $counter++; ?>
	
	<?php endforeach; ?>
        <div class="clr"></div>
	</div>
	<?php endif; ?>    
    
    <?php if (!empty($this->link_items)) : ?>
    <ul class="catLinkList">
    	<?php foreach ($this->link_items as $key => &$item) : ?>
	<?php
		$key= $key-$leadingcount-$introcount;		
		 ?>    
        <li<?php if($key+1==sizeof($this->link_items)) echo ' class="last"';?>>     	
		<?php
			$this->item = &$item;
			echo $this->loadTemplate('link');
		?>
        </li>

	<?php $counter++; ?>
	
	<?php endforeach; ?>
    </ul>
    <?php endif; ?>    
    
<?php if (($this->params->def('show_pagination', 1) == 1  || ($this->params->get('show_pagination') == 2)) && ($this->pagination->get('pages.total') > 1)) : ?>
		<div class="pageNav">
			<?php  if ($this->params->def('show_pagination_results', 1)) : ?>
				<div class="pageCounter">
					<?php echo $this->pagination->getPagesCounter(); ?>
				</div>
				<?php endif; ?>                
				<?php echo $this->pagination->getPagesLinks(); ?>
		</div>
<?php  endif; ?>
    
    
    <div class="clr"></div>
    
</div>


